<?php
namespace utils;
class BankUtils
{
	/* The function calculates the Credit Mountly Payment
	 * $creaditAmount - the whole amount of the credit 
	 * $interestRate - yearly interest rate 
	 * $period - period in months 
	 * 
	 * Example for 50 000lv credit, with 6% interest rate for 5 years(120 months)
	 * BankUtils::calculateCreditMontlyPayment(50000, 6, 120);
	 * The result is 555.10lv
	 */
	public static final function calculateCreditMontlyPayment($creaditAmount, $interestRate, $period)
	{
		$interestMultiplyer = 1 + ($interestRate / (100 * 12));
		$montlyPayment = $creaditAmount * pow($interestMultiplyer, $period) * ($interestMultiplyer - 1) / (pow($interestMultiplyer, $period) - 1);
		
		return round($montlyPayment,2);
	}

	/* The function calculate Deposit Monthly Payment
	 * $depositAmount - amount on deposit in the bank
	 * $interestRate - yearly interest rate
	 * 
	 * Example for 50000lv deposit, with 3% interest rate
	 * BankUtils::calculateDepositMontlyPayment(50000, 3);
	 * The result is 125lv
	 */
	public static final function calculateDepositMontlyPayment($depositAmount, $interestRate)
	{
		$montlyPayment = $depositAmount * ($interestRate / (100 * 12));
		
		return round($montlyPayment, 2);
	}
}

?>